package com.demo.resourcecode.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.demo.resourcecode.condition.Bean1;
import com.demo.resourcecode.condition.Bean2;

/**
 * 如果类上没有@Configuration注解，那么下面的写法：
	@Bean
	public Bean1 bean1(){
		System.out.println(bean2());
		System.out.println(bean2());
		System.out.println(bean2());
	}
	
	@Bean
	public Bean2 bean2(){
		return new Bean2();
	}
会生成三个bean2对象。

加上@Configuration注解，那么该配置类会被代理，此时再调用bean2()会被代理类拦截，可以基于bean2()得到beanName，直接返回bean
 * */
@Configuration
public class Configuration1 {

    @Bean
    public Bean1 bean1() {
    	System.out.println(bean2());
    	System.out.println(bean2());
        return new Bean1();
    }
    
    @Bean
    public Bean2 bean2() {
    	return new Bean2();
    }

}
